# Maintainer: Konstantin Gizdov <arch at kge dot pw>
# Contributor: Jingbei Li <i@jingbei.li>
# Contributor: Intel Corporation <http://www.intel.com/software/products/support>

_pkgname='intel-oneapi'
pkgname="${_pkgname}-common"
pkgver='2023.0.0'
_debpkgrel='25325'
pkgrel=3
pkgdesc="Intel's oneAPI common variables and licensing"
arch=('any')
url='https://software.intel.com/content/www/us/en/develop/tools/oneapi.html'
license=("custom")
source=("https://apt.repos.intel.com/oneapi/pool/main/${pkgname}-vars-${pkgver}-${_debpkgrel}_all.deb"
        "https://apt.repos.intel.com/oneapi/pool/main/${pkgname}-licensing-${pkgver}-${pkgver}-${_debpkgrel}_all.deb")
b2sums=('78f6d8c1e79711876dd5e92a6b2774fc52f3234707d6f097064398098bd3e4d26d960e31ccca01cdddb5e4483057c7a5e1fff85ab533287bff74152490d04f44'
        '31944e1ed8fa34669d2ae4f1c8ea6280cb921a319abfe0e23f472574816404331627baf41e76bf9031656fdecb64e3ac025edbecf3765b840f0693907020b163')
depends=('sh')
optdepends=("procps-ng: Sourcing /opt/intel/oneapi/setvars.sh")
noextract=(
    "${pkgname}-vars-${pkgver}-${_debpkgrel}_all.deb"
    "${pkgname}-licensing-${pkgver}-${pkgver}-${_debpkgrel}_all.deb"
)
conflicts=('intel-oneapi-basekit')

build() {
    mkdir vars licensing package

}

package() {
    cd "${srcdir}"
    ar x "${srcdir}/${pkgname}-vars-${pkgver}-${_debpkgrel}_all.deb"
    tar xvf data.tar.xz -C "${pkgdir}"
    rm data.tar.xz

    ar x "${srcdir}/${pkgname}-licensing-${pkgver}-${pkgver}-${_debpkgrel}_all.deb"
    tar xvf data.tar.xz -C "${pkgdir}"
    rm data.tar.xz

    ln -sfT "${pkgver}" "${pkgdir}"/opt/intel/oneapi/licensing/latest
    install -d "${pkgdir}"/usr/share/licenses/"${pkgname}"
    ln -s /opt/intel/oneapi/licensing/latest "${pkgdir}"/usr/share/licenses/"${pkgname}"/latest
    ln -s "${pkgname}" "${pkgdir}"/usr/share/licenses/"${_pkgname}"
    ls -lah "${pkgdir}"/usr/share/licenses
}
